1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 import javax.security.auth.*;
32
33 public class CanonError {
34
35 public static void main(String[] args) {
36
37
38 PrivateCredentialPermission pcp1 = new PrivateCredentialPermission
39 ("a b \"pcp1\"", "read");
40 PrivateCredentialPermission pcp2 = new PrivateCredentialPermission
41 ("a b \"pcp1\"", "read");
42 if (!pcp1.equals(pcp2) || !pcp2.equals(pcp1))
43 throw new SecurityException("CanonError test failed: #1");
44 if (!pcp1.implies(pcp2) || !pcp2.implies(pcp1))
45 throw new SecurityException("CanonError test failed: #2");
46
47
48 PrivateCredentialPermission pcp3 = new PrivateCredentialPermission
49 ("a b \"pcp3\"", "read");
50 if (pcp1.equals(pcp3) || pcp3.equals(pcp1))
51 throw new SecurityException("CanonError test failed: #3");
52 if (pcp1.implies(pcp3) || pcp3.implies(pcp1))
53 throw new SecurityException("CanonError test failed: #4");
54
55
56 PrivateCredentialPermission pcp_4 = new PrivateCredentialPermission
57 ("a b \"pcp 4\"", "read");
58 PrivateCredentialPermission pcp__4 = new PrivateCredentialPermission
59 ("a b \"pcp 4\"", "read");
60 if (pcp_4.equals(pcp__4) || pcp__4.equals(pcp_4))
61 throw new SecurityException("CanonError test failed: #5");
62 if (pcp_4.implies(pcp__4) || pcp__4.implies(pcp_4))
63 throw new SecurityException("CanonError test failed: #6");
64
65 String credClass = pcp__4.getCredentialClass();
66 System.out.println("credentialClass = " + credClass);
67 String[][] principals = pcp__4.getPrincipals();
68 if (!principals[0][1].equals("pcp 4"))
69 throw new SecurityException("CanonError test failed: #7");
70 for (int i = 0; i < principals.length; i++) {
71 for (int j = 0; j < 2; j++) {
72 System.out.println("principals[" + i + "][" + j + "] = " +
73 principals[i][j]);
74 }
75 }
76
77 credClass = pcp_4.getCredentialClass();
78 System.out.println("credentialClass = " + credClass);
79 principals = pcp_4.getPrincipals();
80 if (!principals[0][1].equals("pcp 4"))
81 throw new SecurityException("CanonError test failed: #8");
82 for (int i = 0; i < principals.length; i++) {
83 for (int j = 0; j < 2; j++) {
84 System.out.println("principals[" + i + "][" + j + "] = " +
85 principals[i][j]);
86 }
87 }
88
89 System.out.println("CanonError test passed");
90 }
91 }